import time

import pytest
import os,sys
sys.path.append(os.getcwd())


from utils.readYaml import read_cesi_data
from utils.init_driver import initDriver
from utils.readConfigFileUtils import readConfig

from service.service_form import ServiceForm


class TestForm(object):
    def setup_class(self):
        #初始化base_url
        a=readConfig("config/webConfig.yaml")
        self.base_url=f"{a['xieyi']}{a['yumin']}:{a['port']}"


    def teardown_class(self):
        print("teardown_class被执行啦")

    def setup(self):
        #初始化driver
        self.driver=initDriver(isHeadless=False)
        #初始化业务对象
        self.serviceForm=ServiceForm(self.driver,self.base_url)



    def teardown(self):
        time.sleep(5)
        self.driver.quit()

    @pytest.mark.parametrize("d", read_cesi_data("data/form.yaml","test_form_01"))
    def test_form_01(self,d):
        assert self.serviceForm.service_from_01(d)






